
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rie06.openvoip.client.IHM.communication;

import com.rie06.openvoip.client.Contact;
import com.rie06.openvoip.client.Conversation;
import com.sun.media.codec.video.cinepak.CPChunk;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.*;
import org.apache.log4j.Logger;

/**
 * @author spe
 */
public class PanelContactConversation extends JPanel {

    private CommunicationController communicationController;
    private JLabel labelTextName;
    private JLabel labelStatus;
    private JLabel labelSeparator;
    private JButton muteContactButton;
    private JButton deleteContactButton;
    private JButton soundContactButton;
    private ImageIcon iconMute;
    private ImageIcon iconSound;
    private Contact contact;
    private Conversation conversation;
    private Color color = Color.orange;
    private PanelDialog panelDialog;
    private static final Logger logger = Logger.getLogger(PanelContactConversation.class);

    public PanelContactConversation(CommunicationController communicationController, PanelDialog panelDialog, Contact contact) {
        
        this.communicationController = communicationController;
        this.setBackground(color);
        this.contact = contact;
        this.conversation = panelDialog.getDialogWindow().getConversation();
        this.setPreferredSize(new Dimension(350, 50));
        this.panelDialog = panelDialog;

        labelTextName = new JLabel(contact.getName());
        labelStatus = new JLabel(" : ");
        labelSeparator = new JLabel("");

        iconMute = new ImageIcon("images/mute16.png");
        muteContactButton = new JButton(iconMute);
        muteContactButton.setVisible(true);
        muteContactButton.addActionListener(communicationController);
        muteContactButton.setActionCommand("muteButton");

        iconSound = new ImageIcon("images/sound.png");
        soundContactButton = new JButton(iconSound);
        soundContactButton.setVisible(false);
        soundContactButton.addActionListener(communicationController);
        soundContactButton.setActionCommand("soundButton");

        if (conversation.isMaster()) {
            ImageIcon iconDelete = new ImageIcon("images/delete16.png");
            deleteContactButton = new JButton(iconDelete);
            deleteContactButton.addActionListener(communicationController);
            deleteContactButton.setActionCommand("deleteButton");
        }

        this.add(labelTextName);
        this.add(labelStatus);
        this.add(labelSeparator);

        this.add(muteContactButton);
        this.add(soundContactButton);
        if (conversation.isMaster()) {
            this.add(deleteContactButton);
        }

    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
        this.setBackground(this.color);
        this.repaint();
        this.revalidate();
    }

    public JLabel getLabelTextName() {
        return labelTextName;
    }

    public void setLabelTextName(JLabel labelTextName) {
        this.labelTextName = labelTextName;
    }

    public JLabel getLabelTextStatus() {
        return labelSeparator;
    }

    public void setLabelTextStatus(JLabel labelTextStatus) {
        this.labelSeparator = labelTextStatus;
    }

    public JButton getDeleteContactButton() {
        return deleteContactButton;
    }

    public void setDeleteContactButton(JButton deleteContactButton) {
        this.deleteContactButton = deleteContactButton;
    }

    public JButton getMuteContactButton() {
        return muteContactButton;
    }

    public JButton getSoundContactButton() {
        return soundContactButton;
    }

    public PanelDialog getPanelDialog() {
        return panelDialog;
    }

    public Contact getContact() {
        return contact;
    }

    public Conversation getConversation() {
        return conversation;
    }
}
